﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Data;

namespace ly.Web.Admin
{
    public partial class editWork : System.Web.UI.Page
    {
        ly.BLL.WorkInfo workBll = new BLL.WorkInfo();
        ly.Model.WorkInfo workModel = new Model.WorkInfo();
        protected void Page_Load(object sender, EventArgs e)
        {
            if (!IsPostBack)
            {
                int workid = Convert.ToInt16(Request["id"].Trim());
                string strwhere = "WorkID = " + workid;
                DataTable dt = workBll.GetList(strwhere).Tables[0];
                if (dt.Rows.Count > 0)
                {
                    txtworkname.Text = dt.Rows[0]["WorkName"].ToString().Trim();
                    txtusername.Text = dt.Rows[0]["UserName"].ToString().Trim();
                    //图片如何实现传递呢？
                    startTime.Value = dt.Rows[0]["UploadTime"].ToString().Trim();
                    ddlwork.SelectedValue = dt.Rows[0]["ActivityID"].ToString().Trim();
                    FCKeditor1.Value = dt.Rows[0]["WorkIntroduction"].ToString().Trim();
                    //ddltype.Text = dt.Rows[0]["Type"].ToString().Trim();

                }
            }
        }

        protected void btntianjia_Click(object sender, EventArgs e)
        {
            workModel = workBll.GetModel(Convert.ToInt32(Request["id"].Trim()));
            workModel.WorkName = txtworkname.Text.Trim();
            workModel.UserName = txtusername.Text.Trim();
            workModel.UploadTime = Convert.ToDateTime(startTime.Value.Trim());
            workModel.WorkIntroduction = FCKeditor1.Value.Trim();
            bool cou = workBll.Update(workModel);
            if (cou)
            {
                ClientScript.RegisterStartupScript(this.GetType(), "", "<script>alert('更改成功');</script>");
                Response.Redirect("workManager.aspx");
                //Maticsoft.Common.MessageBox.ShowAndRedirect(this, "更改成功", "activityManager.aspx");
            }
            else
            {
                ClientScript.RegisterStartupScript(this.GetType(), "", "<script>alert('更改失败');</script>");
            }
        }
    }
}